package org.come.xingpan;

import com.tool.btn.MoBanBtn;
import com.tool.image.ImageMixDeal;
import com.tool.role.BaseXingpans;
import com.tool.role.RoleData;
import com.tool.role.RoleProperty;
import com.tool.tcpimg.UIUtils;
import org.come.Frame.ShoppingBuyJframe;
import org.come.Frame.ZhuFrame;
import org.come.action.MapAction;
import org.come.bean.PrivateData;
import org.come.entity.Goodstable;
import org.come.model.Shop;
import org.come.socket.Agreement;
import org.come.socket.SendMessageUntil;
import org.come.until.*;

import javax.script.ScriptEngine;
import javax.script.ScriptEngineManager;
import javax.swing.*;
import java.awt.*;
import java.awt.event.MouseEvent;
import java.math.BigDecimal;
import java.util.Vector;
import java.util.List;
import java.util.regex.Matcher;
import java.util.regex.Pattern;

public class BtnStarCard extends MoBanBtn {

    /**
     * jpanelXingCardMain面板按钮:<br>
     * 1星图菜单按钮<br>
     * 2强化菜单按钮<br>
     * 3洗练菜单按钮<br>
     * 4升级子菜单按钮<br>
     * 5重洗子菜单按钮<br>
     * 6练星子菜单按钮<br>
     * lockBtn锁图标11<br>
     * unlockBtn解锁图标12<br>
     * attributeMenuBtn星图按钮1<br>
     * recastMenuBtn强化按钮2<br>
     * cultivateBtn洗练按钮3<br>
     * upgradeBtn星魂按钮4<br>
     * redoBtn屬性按钮5<br>
     * lianStarBtn分解按钮6<br>
     * caozuoBtn坤按钮20<br>天巧 天哭 天暴 天慧 天牢 天牢 8
     * joinBtn艮按钮21<br> 	天损  天罪 天竟 天剑 天寿 7
     * fetchBtn坎按钮22<br>	天退 天究 天微  天杀 天异 6
     * soulBackBtn巽按钮23<br> 天速  天空 天佑  天暗 5
     * exchangeBtn震按钮24<br>天捷 天立 天伤  天孤 天满 4
     * supplementBtn离按钮25<br> 天富 天贵  天英  天威 3
     * deleteBtn兑按钮26<br> 天猛 天雄  天勇 天闲 2
     * transferBtn乾按钮27<br> 天机 天罡 天魁 1
     * JpanelXingBackMain面板按钮:<br>
     * 30确认按钮<br>
     * 31取消按钮<br>
     * 32 激活大招<br>
     * 33 兑换<br>
     */
    private int caozuo;
    private JpanelXingBackMain jpanelXingBackMain;
    private JpanelXingCardMain jpanelXingCardMain;

    public BtnStarCard(String iconpath, int type, String text, int caozuo, JpanelXingCardMain jpanelXingCardMain) {
        super(iconpath, type);
        this.caozuo = caozuo;
        if (caozuo >= 20) {
            setText(text);
            setHorizontalTextPosition(SwingConstants.CENTER);
            setVerticalTextPosition(SwingConstants.CENTER);
            setForeground(Color.yellow);
            setFont(UIUtils.TEXT_HY17);
        }
        this.jpanelXingCardMain = jpanelXingCardMain;
    }

//    public BtnStarCard(String iconpath, int type, Color[] colors, Font font, String text, int caozuo,
//                       JpanelXingCardMain jpanelXingCardMain) {
//        super(iconpath, type, colors);
//        this.caozuo = caozuo;
//        if (caozuo >= 20) {
//        setText(text);
//        setHorizontalTextPosition(SwingConstants.CENTER);
//        setVerticalTextPosition(SwingConstants.CENTER);
//        setFont(font);
//        }
//        this.jpanelXingCardMain = jpanelXingCardMain;
//    }

    public BtnStarCard(String iconpath, int type, Color[] colors, Font font, String text, int caozuo,
                       JpanelXingCardMain jpanelXingCardMain) {
        super(iconpath, type, colors);
        this.caozuo = caozuo;
        setText(text);
        setHorizontalTextPosition(SwingConstants.CENTER);
        setVerticalTextPosition(SwingConstants.CENTER);
        setFont(font);
        this.jpanelXingCardMain = jpanelXingCardMain;
    }
    public BtnStarCard(String iconpath, int type, Color[] colors, Font font, String text, int caozuo,
                       JpanelXingBackMain jpanelXingBackMain) {
        super(iconpath, type, colors);
        this.caozuo = caozuo;
        setText(text);
        setHorizontalTextPosition(SwingConstants.CENTER);
        setVerticalTextPosition(SwingConstants.CENTER);
        setFont(font);

        this.jpanelXingBackMain = jpanelXingBackMain;
    }







    @Override
    public void chooseyes() {

    }

    @Override
    public void chooseno() {

    }

    /**
     * 按钮点击事件
     * @param e
     */
    @Override
    public void nochoose(MouseEvent e) {
        if (ImageMixDeal.userimg.getRoleShow().getBooth_id() != null) {
            ZhuFrame.getZhuJpanel().addPrompt2("摆摊状态不可以操作！");
            return;
        }
        try {
            //星盘界面功能切换
            if (caozuo == 1) {
                jpanelXingCardMain.setIsPlayXPKM(true);
                jpanelXingCardMain.getLianStarBtn().setText("激活");
                jpanelXingCardMain.setBigType(1);
//                jpanelXingCardMain.changeBigMenuLeftView1(1);
            } else if (caozuo == 2) {
                jpanelXingCardMain.setIsPlayXPKM(true);
                jpanelXingCardMain.getLianStarBtn().setText("强化");
                jpanelXingCardMain.setBigType(2);
//                jpanelXingCardMain.changeBigMenuLeftView1(2);
            } else if (caozuo == 3) {
                jpanelXingCardMain.setIsPlayXPKM(true);
                jpanelXingCardMain.getLianStarBtn().setText("洗练");
                jpanelXingCardMain.setBigType(3);
//                jpanelXingCardMain.changeBigMenuLeftView1(3);
            }
            //打开星魂界面
            else if (caozuo == 4) {
                FormsManagement.showForm(121);

            }
            //属性界面
            else if (caozuo == 5) {
                FormsManagement.showForm(603);
            }
            //激活界面
            else if (caozuo == 6) {

                PrivateData privateData = RoleData.getRoleData().getPrivateData();
                int num = jpanelXingCardMain.getRadioType();
                if(num==-1) {
                    ZhuFrame.getZhuJpanel().addPrompt2("选择一个星盘");
                    return;
                }
                Vector<BaseXingpans> xingpansVector = RoleProperty.getRoleProperty().xingpanVector;
                boolean aa = true;

                //过滤当前星图是否激活全部的星魂
                for (int z = 0; z < xingpansVector.size(); z++) {
                    BaseXingpans baseXingpans = xingpansVector.get(z);
                    if (baseXingpans.getBh()==num) {
                        aa = false;

                    }
                }
                if(aa) {
                    ZhuFrame.getZhuJpanel().addPrompt2("星魂没有全部激活");
                    return;
                }

                if("激活".equals(jpanelXingCardMain.getLianStarBtn().getText())) {
                    //学习技能
                    if(num==1) {
                        for (int z = 0; z < xingpansVector.size(); z++) {
                            BaseXingpans baseXingpans = xingpansVector.get(z);
                            if (baseXingpans.getBh()==1) {
                                String vvvvv = unicodeStr2String(baseXingpans.getExp());
                                String[] vvvv=vvvvv.split("=");
                                if (vvvv.length<6) {
                                    ZhuFrame.getZhuJpanel().addPrompt2("星魂没有全部激活");
                                    return;
                                }

                            }
                        }
                        aa = true;
                        RoleData.getRoleData().getPrivateData().setSkills("X", null);
                        SendRoleAndRolesummingUntil.sendRole(RoleData.getRoleData().getPrivateData());
                        MapAction.npcmenuAction.get(NpcMenuUntil.XPSKILL).menuControl("源源不绝");
                    }else if(num==2) {
                        for (int z = 0; z < xingpansVector.size(); z++) {
                            BaseXingpans baseXingpans = xingpansVector.get(z);
                            if (baseXingpans.getBh()==2) {
                                String vvvvv = unicodeStr2String(baseXingpans.getExp());
                                String[] vvvv=vvvvv.split("=");
                                if (vvvv.length<5) {
                                    ZhuFrame.getZhuJpanel().addPrompt2("星魂没有全部激活");
                                    return;
                                }

                            }
                        }
                        aa = true;
                        RoleData.getRoleData().getPrivateData().setSkills("X", null);
                        SendRoleAndRolesummingUntil.sendRole(RoleData.getRoleData().getPrivateData());
                        MapAction.npcmenuAction.get(NpcMenuUntil.XPSKILL).menuControl("幻影谜踪");
                    }else if(num==3) {
                        for (int z = 0; z < xingpansVector.size(); z++) {
                            BaseXingpans baseXingpans = xingpansVector.get(z);
                            if (baseXingpans.getBh()==3) {
                                String vvvvv = unicodeStr2String(baseXingpans.getExp());
                                String[] vvvv=vvvvv.split("=");
                                if (vvvv.length<5) {
                                    ZhuFrame.getZhuJpanel().addPrompt2("星魂没有全部激活");
                                    return;
                                }

                            }
                        }
                        aa = true;
                        RoleData.getRoleData().getPrivateData().setSkills("X", null);
                        SendRoleAndRolesummingUntil.sendRole(RoleData.getRoleData().getPrivateData());
                        MapAction.npcmenuAction.get(NpcMenuUntil.XPSKILL).menuControl("力击八方");
                    }else if(num==4) {
                        for (int z = 0; z < xingpansVector.size(); z++) {
                            BaseXingpans baseXingpans = xingpansVector.get(z);
                            if (baseXingpans.getBh()==4) {
                                String vvvvv = unicodeStr2String(baseXingpans.getExp());
                                String[] vvvv=vvvvv.split("=");
                                if (vvvv.length<4) {
                                    ZhuFrame.getZhuJpanel().addPrompt2("星魂没有全部激活");
                                    return;
                                }

                            }
                        }
                        aa = true;
                        RoleData.getRoleData().getPrivateData().setSkills("X", null);
                        SendRoleAndRolesummingUntil.sendRole(RoleData.getRoleData().getPrivateData());
                        MapAction.npcmenuAction.get(NpcMenuUntil.XPSKILL).menuControl("荆棘束身");
                    }else if(num==5) {
                        for (int z = 0; z < xingpansVector.size(); z++) {
                            BaseXingpans baseXingpans = xingpansVector.get(z);
                            if (baseXingpans.getBh()==5) {
                                String vvvvv = unicodeStr2String(baseXingpans.getExp());
                                String[] vvvv=vvvvv.split("=");
                                if (vvvv.length<5) {
                                    ZhuFrame.getZhuJpanel().addPrompt2("星魂没有全部激活");
                                    return;
                                }

                            }
                        }
                        aa = true;
                        RoleData.getRoleData().getPrivateData().setSkills("X", null);
                        SendRoleAndRolesummingUntil.sendRole(RoleData.getRoleData().getPrivateData());
                        MapAction.npcmenuAction.get(NpcMenuUntil.XPSKILL).menuControl("神清气正");
                    }else if(num==6) {
                        for (int z = 0; z < xingpansVector.size(); z++) {
                            BaseXingpans baseXingpans = xingpansVector.get(z);
                            if (baseXingpans.getBh()==6) {
                                String vvvvv = unicodeStr2String(baseXingpans.getExp());
                                String[] vvvv=vvvvv.split("=");
                                if (vvvv.length<4) {
                                    ZhuFrame.getZhuJpanel().addPrompt2("星魂没有全部激活");
                                    return;
                                }

                            }
                        }
                        aa = true;
                        RoleData.getRoleData().getPrivateData().setSkills("X", null);
                        SendRoleAndRolesummingUntil.sendRole(RoleData.getRoleData().getPrivateData());
                        MapAction.npcmenuAction.get(NpcMenuUntil.XPSKILL).menuControl("雾掩青山");
                    }else if(num==7) {
                        for (int z = 0; z < xingpansVector.size(); z++) {
                            BaseXingpans baseXingpans = xingpansVector.get(z);
                            if (baseXingpans.getBh()==7) {
                                String vvvvv = unicodeStr2String(baseXingpans.getExp());
                                String[] vvvv=vvvvv.split("=");
                                if (vvvv.length<4) {
                                    ZhuFrame.getZhuJpanel().addPrompt2("星魂没有全部激活");
                                    return;
                                }
                            }
                        }
                        aa = true;
                        RoleData.getRoleData().getPrivateData().setSkills("X", null);
                        SendRoleAndRolesummingUntil.sendRole(RoleData.getRoleData().getPrivateData());
                        MapAction.npcmenuAction.get(NpcMenuUntil.XPSKILL).menuControl("知耻后勇");
                    }else if(num==8) {
                        for (int z = 0; z < xingpansVector.size(); z++) {
                            BaseXingpans baseXingpans = xingpansVector.get(z);
                            if (baseXingpans.getBh()==8) {
                                String vvvvv = unicodeStr2String(baseXingpans.getExp());
                                String[] vvvv=vvvvv.split("=");
                                if (vvvv.length<3) {
                                    ZhuFrame.getZhuJpanel().addPrompt2("星魂没有全部激活");
                                    return;
                                }

                            }
                        }
                        aa = true;
                        RoleData.getRoleData().getPrivateData().setSkills("X", null);
                        SendRoleAndRolesummingUntil.sendRole(RoleData.getRoleData().getPrivateData());
                        MapAction.npcmenuAction.get(NpcMenuUntil.XPSKILL).menuControl("甘霖瑞雪");
                    }
                }else if("强化".equals(jpanelXingCardMain.getLianStarBtn().getText())) {
                    //升级等级

                    if(num==1) {
                        for (int z = 0; z < xingpansVector.size(); z++) {
                            BaseXingpans baseXingpans = xingpansVector.get(z);
                            if (baseXingpans.getBh()==1) {
                                String vvvvv = unicodeStr2String(baseXingpans.getExp());
                                String[] vvvv=vvvvv.split("=");
                                if (vvvv.length<6) {
                                    ZhuFrame.getZhuJpanel().addPrompt2("星魂没有全部激活");
                                    return;
                                }

                            }
                        }
                        aa = true;
                    }else if(num==2) {
                        for (int z = 0; z < xingpansVector.size(); z++) {
                            BaseXingpans baseXingpans = xingpansVector.get(z);
                            if (baseXingpans.getBh()==2) {
                                String vvvvv = unicodeStr2String(baseXingpans.getExp());
                                String[] vvvv=vvvvv.split("=");
                                if (vvvv.length<5) {
                                    ZhuFrame.getZhuJpanel().addPrompt2("星魂没有全部激活");
                                    return;
                                }

                            }
                        }
                        aa = true;
                    }else if(num==3) {
                        for (int z = 0; z < xingpansVector.size(); z++) {
                            BaseXingpans baseXingpans = xingpansVector.get(z);
                            if (baseXingpans.getBh()==3) {
                                String vvvvv = unicodeStr2String(baseXingpans.getExp());
                                String[] vvvv=vvvvv.split("=");
                                if (vvvv.length<5) {
                                    ZhuFrame.getZhuJpanel().addPrompt2("星魂没有全部激活");
                                    return;
                                }
                            }
                        }
                        aa = true;

                    }else if(num==4) {
                        for (int z = 0; z < xingpansVector.size(); z++) {
                            BaseXingpans baseXingpans = xingpansVector.get(z);
                            if (baseXingpans.getBh()==4) {
                                String vvvvv = unicodeStr2String(baseXingpans.getExp());
                                String[] vvvv=vvvvv.split("=");
                                if (vvvv.length<4) {
                                    ZhuFrame.getZhuJpanel().addPrompt2("星魂没有全部激活");
                                    return;
                                }
                            }
                        }
                        aa = true;

                    }else if(num==5) {
                        for (int z = 0; z < xingpansVector.size(); z++) {
                            BaseXingpans baseXingpans = xingpansVector.get(z);
                            if (baseXingpans.getBh()==5) {

                                String vvvvv = unicodeStr2String(baseXingpans.getExp());
                                String[] vvvv=vvvvv.split("=");
                                if (vvvv.length<5) {
                                    ZhuFrame.getZhuJpanel().addPrompt2("星魂没有全部激活");
                                    return;
                                }
                            }
                        }
                        aa = true;

                    }else if(num==6) {
                        for (int z = 0; z < xingpansVector.size(); z++) {
                            BaseXingpans baseXingpans = xingpansVector.get(z);
                            if (baseXingpans.getBh()==6) {
                                String vvvvv = unicodeStr2String(baseXingpans.getExp());
                                String[] vvvv=vvvvv.split("=");
                                if (vvvv.length<4) {
                                    ZhuFrame.getZhuJpanel().addPrompt2("星魂没有全部激活");
                                    return;
                                }
                            }
                        }
                        aa = true;
                    }else if(num==7) {

                        for (int z = 0; z < xingpansVector.size(); z++) {
                            BaseXingpans baseXingpans = xingpansVector.get(z);
                            if (baseXingpans.getBh()==8) {
                                String vvvvv = unicodeStr2String(baseXingpans.getExp());
                                String[] vvvv=vvvvv.split("=");
                                if (vvvv.length<3) {
                                    ZhuFrame.getZhuJpanel().addPrompt2("星魂没有全部激活");
                                    return;
                                }
                            }
                        }
                        aa = true;
                        if (examinationXPStatus(xingpansVector)) return;
                    }else if(num==8) {
                        for (int z = 0; z < xingpansVector.size(); z++) {
                            BaseXingpans baseXingpans = xingpansVector.get(z);
                            if (baseXingpans.getBh()==8) {
                                String vvvvv = unicodeStr2String(baseXingpans.getExp());
                                String[] vvvv=vvvvv.split("=");
                                if (vvvv.length<3) {
                                    ZhuFrame.getZhuJpanel().addPrompt2("星魂没有全部激活");
                                    return;
                                }
                            }
                        }
                        aa = true;
                    }
                    SendMessageUntil.toServer(Agreement.getAgreement().rolechangeAgreement("Z3"+num+(num+1)));
                }else if("洗练".equals(jpanelXingCardMain.getLianStarBtn().getText())) {

                    BigDecimal big = RoleData.getRoleData().getLoginResult().getScoretype("魂值") != null ? RoleData
                            .getRoleData().getLoginResult().getScoretype("魂值")
                            : new BigDecimal(0);
                    if(big.compareTo(new BigDecimal(0))<1) {
                        ZhuFrame.getZhuJpanel().addPrompt2("魂值不足");
                        return;
                    }
                    SendMessageUntil.toServer(Agreement.getAgreement().rolechangeAgreement("Z4"+num+(num+1)));

                }
                jpanelXingCardMain.changeBigMenuLeftView1(jpanelXingCardMain.getBigType());
            } else if (caozuo == 11) {
                MessagrFlagUntil.setMouse(MessagrFlagUntil.MOUSE10);
            } else if (caozuo == 12) {
                if (Util.canBuyOrno) {// 已解锁
                    MessagrFlagUntil.setMouse(MessagrFlagUntil.MOUSE11);
                } else {// 未解锁
                    if (RoleData.getRoleData().getLoginResult().getPassword() == null) {
                        FormsManagement.showForm(32);
                    } else {
                        FormsManagement.showForm(33);
                    }
                }
            } else if (caozuo == 20) {
                jpanelXingCardMain.getCardBackImg().setIcon(CutButtonImage.getImage("inkImg/old/1/xpbj8.png", 250, 250));
                jpanelXingCardMain.setRadioType(1);
                jpanelXingCardMain.getCardImg().setText("源源不绝");
                jpanelXingCardMain.getCardImg().setIcon(CutButtonImage.getImage("inkImg/hongmu/soaringSkill/40×40/23001.png", 50, 50));
                jpanelXingCardMain.setIsPlayXPKM(true);
            } else if (caozuo == 21) {
                jpanelXingCardMain.getCardBackImg().setIcon(CutButtonImage.getImage("inkImg/old/1/xpbj7.png", 250, 250));
                jpanelXingCardMain.setRadioType(2);
                jpanelXingCardMain.getCardImg().setText("幻影谜踪");
                jpanelXingCardMain.getCardImg().setIcon(CutButtonImage.getImage("inkImg/hongmu/soaringSkill/40×40/23002.png", 50, 50));
                jpanelXingCardMain.setIsPlayXPKM(true);
            } else if (caozuo == 22) {
                jpanelXingCardMain.getCardBackImg().setIcon(CutButtonImage.getImage("inkImg/old/1/xpbj6.png", 250, 250));
                jpanelXingCardMain.setRadioType(3);
                jpanelXingCardMain.getCardImg().setText("力击八方");
                jpanelXingCardMain.getCardImg().setIcon(CutButtonImage.getImage("inkImg/hongmu/soaringSkill/40×40/23003.png", 50, 50));
                jpanelXingCardMain.setIsPlayXPKM(true);
            } else if (caozuo == 23) {
                jpanelXingCardMain.getCardBackImg().setIcon(CutButtonImage.getImage("inkImg/old/1/xpbj5.png", 250, 250));
                jpanelXingCardMain.setRadioType(4);
                jpanelXingCardMain.getCardImg().setText("荆棘束身");
                jpanelXingCardMain.getCardImg().setIcon(CutButtonImage.getImage("inkImg/hongmu/soaringSkill/40×40/23004.png", 50, 50));
                jpanelXingCardMain.setIsPlayXPKM(true);
            } else if (caozuo == 24) {
                jpanelXingCardMain.getCardBackImg().setIcon(CutButtonImage.getImage("inkImg/old/1/xpbj4.png", 250, 250));
                jpanelXingCardMain.setRadioType(5);
                jpanelXingCardMain.getCardImg().setText("神清气正");
                jpanelXingCardMain.getCardImg().setIcon(CutButtonImage.getImage("inkImg/hongmu/soaringSkill/40×40/23005.png", 50, 50));
                jpanelXingCardMain.setIsPlayXPKM(true);
            } else if (caozuo == 25) {
                jpanelXingCardMain.getCardBackImg().setIcon(CutButtonImage.getImage("inkImg/old/1/xpbj3.png", 250, 250));
                jpanelXingCardMain.setRadioType(6);
                jpanelXingCardMain.getCardImg().setText("雾掩青山");
                jpanelXingCardMain.getCardImg().setIcon(CutButtonImage.getImage("inkImg/hongmu/soaringSkill/40×40/23006.png", 50, 50));
                jpanelXingCardMain.setIsPlayXPKM(true);
            } else if (caozuo == 26) {
                jpanelXingCardMain.getCardBackImg().setIcon(CutButtonImage.getImage("inkImg/old/1/xpbj2.png", 250, 250));
                jpanelXingCardMain.setRadioType(7);
                jpanelXingCardMain.getCardImg().setText("知耻后勇");
                jpanelXingCardMain.getCardImg().setIcon(CutButtonImage.getImage("inkImg/hongmu/soaringSkill/40×40/23007.png", 50, 50));
                jpanelXingCardMain.setIsPlayXPKM(true);
            } else if (caozuo == 27) {
                jpanelXingCardMain.getCardBackImg().setIcon(CutButtonImage.getImage("inkImg/old/1/xpbj1.png", 250, 250));
                jpanelXingCardMain.setRadioType(8);
                jpanelXingCardMain.getCardImg().setText("甘霖瑞雪");
                jpanelXingCardMain.getCardImg().setIcon(CutButtonImage.getImage("inkImg/hongmu/soaringSkill/40×40/23008.png", 50, 50));
                jpanelXingCardMain.setIsPlayXPKM(true);
            } else if (caozuo == 30) {
                int num = jpanelXingBackMain.getChooseNum();
                if(num==-1) {
                    ZhuFrame.getZhuJpanel().addPrompt2("选择一个星魂");
                    return;
                }
                Goodstable goodstable = UserMessUntil.getgoodstable(new BigDecimal(51000+num));
                int goodNum = GoodsListFromServerUntil.getGoodNum(goodstable.getGoodsid());
                if(goodNum<1) {
                    ZhuFrame.getZhuJpanel().addPrompt2("数量不足");
                    return;
                }
                int num1 = 0;
                if(num<6) {
                    num1 = 1;
                }else if(num<11) {
                    num1 = 2;
                }else if(num<16) {
                    num1 = 3;
                }else if(num<20) {
                    num1 = 4;
                }else if(num<25) {
                    num1 = 5;
                }else if(num<29) {
                    num1 = 6;
                }else if(num<33) {
                    num1 = 7;
                }else if(num<36) {
                    num1 = 8;
                }

                SendMessageUntil.toServer(Agreement.getAgreement().rolechangeAgreement("Z1"+num1+(num+1)));
                for (int i = 0; i < jpanelXingBackMain.getShuliang().length; i++) {
                    goodstable = UserMessUntil.getgoodstable(new BigDecimal(51000+i));
                    goodNum = GoodsListFromServerUntil.getGoodNum(goodstable.getGoodsid());
                    jpanelXingBackMain.getShuliang()[i].setText(""+goodNum);
                }

            } else if (caozuo == 31) {
                int num = jpanelXingBackMain.getChooseNum();
                if(num==-1) {
                    ZhuFrame.getZhuJpanel().addPrompt2("选择一个星魂");
                    return;
                }
                Goodstable goodstable = UserMessUntil.getgoodstable(new BigDecimal(51000+num));
                int goodNum = GoodsListFromServerUntil.getGoodNum(goodstable.getGoodsid());
                if(goodNum<1) {
                    ZhuFrame.getZhuJpanel().addPrompt2("数量不足");
                    return;
                }
                int num1 = 0;
                if(num<6) {
                    num1 = 1;
                }else if(num<11) {
                    num1 = 2;
                }else if(num<16) {
                    num1 = 3;
                }else if(num<20) {
                    num1 = 4;
                }else if(num<25) {
                    num1 = 5;
                }else if(num<29) {
                    num1 = 6;
                }else if(num<33) {
                    num1 = 7;
                }else if(num<36) {
                    num1 = 8;
                }

                RoleData.getRoleData().getLoginResult()
                        .setScore(UserData.Splice(RoleData.getRoleData().getLoginResult().getScore(), "魂值="+(num1*10), 2));

                SendMessageUntil.toServer(Agreement.getAgreement().rolechangeAgreement("Z2"+num1+(num+1)));


            } else if (caozuo == 32) {

                Vector<BaseXingpans> xingpansVector = RoleProperty.getRoleProperty().xingpanVector;
                if(xingpansVector.size()<8) {
                    ZhuFrame.getZhuJpanel().addPrompt2("必须激活全部星魂");
                    return;
                }
                for (int z = 0; z < xingpansVector.size(); z++) {
                    BaseXingpans baseXingpans = xingpansVector.get(z);
                    ScriptEngineManager sem = new ScriptEngineManager();
                    ScriptEngine engine = sem.getEngineByExtension("js");
                    String traseStr = (String)engine.eval("unescape('"+baseXingpans.getExp() +"')");
                    String[] vvvv=traseStr.split("=");

                    if (vvvv.length<3) {
                        ZhuFrame.getZhuJpanel().addPrompt2("必须激活全部星魂");
                        return;
                    }
                }
                RoleData.getRoleData().getPrivateData().setSkills("X", null);
                SendRoleAndRolesummingUntil.sendRole(RoleData.getRoleData().getPrivateData());
                MapAction.npcmenuAction.get(NpcMenuUntil.XPSKILL).menuControl("天罡八卦");
            } else if (caozuo == 33) {
                String npctype = "3058";
                List<Shop> npcshop = (List)UserMessUntil.getNpcshop().getNpcShopMap().get(npctype);
                ShoppingBuyJframe.getShoppingBuyJframe().getShoppingBuyJpanel().showshop(npcshop, npctype, (BigDecimal)null);
                FormsManagement.showForm(23);
            }
        } catch (Exception e1) {
            e1.printStackTrace();
        }
    }

    private boolean examinationXPStatus(Vector<BaseXingpans> xingpansVector) {
        boolean aa;
        for (int z = 0; z < xingpansVector.size(); z++) {
            BaseXingpans baseXingpans = xingpansVector.get(z);
            if (baseXingpans.getBh()==7) {
                String vvvvv = unicodeStr2String(baseXingpans.getExp());
                String[] vvvv=vvvvv.split("=");
                if (vvvv.length<4) {
                    ZhuFrame.getZhuJpanel().addPrompt2("星魂没有全部激活");
                    return true;
                }
            }
        }
        aa = true;
        return false;
    }

    public static String unicode2String(String unicode) {
        StringBuffer string = new StringBuffer();
        String[] hex = unicode.split("\\\\u");

        for (int i = 1; i < hex.length; i++) {
            // 转换出每一个代码点
            int data = Integer.parseInt(hex[i], 16);
            // 追加成string
            string.append((char) data);
        }

        return string.toString();
    }
    public static String unicodeStr2String(String unicodeStr) {
        int length = unicodeStr.length();
        int count = 0;
        /* 正则匹配条件，可匹配“\\u”1到4位，一般是4位可直接使用 String regex = "\\\\u[a-f0-9A-F]{4}";*/
        String regex = "\\\\u[a-f0-9A-F]{1,4}";
        Pattern pattern = Pattern.compile(regex);
        Matcher matcher = pattern.matcher(unicodeStr);
        StringBuffer sb = new StringBuffer();

        while(matcher.find()) {
            String oldChar = matcher.group();//原本的Unicode字符
            String newChar = unicode2String(oldChar);//转换为普通字符
            // int index = unicodeStr.indexOf(oldChar);
            // 在遇见重复出现的unicode代码的时候会造成从源字符串获取非unicode编码字符的时候截取索引越界等
            int index = matcher.start();

            sb.append(unicodeStr.substring(count, index));//添加前面不是unicode的字符
            sb.append(newChar);//添加转换后的字符
            count = index+oldChar.length();//统计下标移动的位置
        }
        sb.append(unicodeStr.substring(count, length));//添加末尾不是Unicode的字符
        return sb.toString();
    }

}
